################################################################################
## CDH1的胚系变异
mkdir -p ${work_dir}/gvcf/

################################################################################
## CDH1的区域
cat ~/ref/GTF/gencode.v19.annotation.gtf | grep -w CDH1 | awk -F'\t' '{OFS="\t"}{print $1,$4,$5}' | sed 's/chr//' \
> ${work_dir}/gvcf/CDH1_region.bed

################################################################################
## Normal样本的bam文件
cat ${config_path}/tumor_normal.class.MSS_MSI.list | awk -F'\t' '{print $2}' | grep -v Normal | sort -u | \
awk '{print bam_path$1"-recal.bam"}' bam_path=${bam_path}/ > ${work_dir}/gvcf/normalBam.list

################################################################################
## 关注CDH1突变
echo " sh ${scripts_path}/germline/jointCalling.sh" | \
qsub -N "jointCalling" -l nodes=1:ppn=5,mem=100gb,walltime=2400:00:00 -q smp -d ${Qsub_log_path}

################################################################################
## 调整AS的header
bcftools view -h ${work_dir}/gvcf/GenotypeGVCFs.vcf.gz > ${work_dir}/gvcf/hdr.txt
cat ${work_dir}/gvcf/hdr.txt | grep -E "##fileformat|##FILTER|##FORMAT|##GATKCommandLine" > ${work_dir}/gvcf/hdr.revise.txt
cat ${work_dir}/gvcf/hdr.txt | grep -v -E "##fileformat|##FILTER|##FORMAT|##GATKCommandLine" | \
grep -v -E "ID=AS_" | grep "##INFO" >> ${work_dir}/gvcf/hdr.revise.txt
cat ${work_dir}/gvcf/hdr.txt | grep  "ID=AS_"  | sed 's/Number=A/Number=0/' >> ${work_dir}/gvcf/hdr.revise.txt
cat ${work_dir}/gvcf/hdr.txt | grep -v -E "##fileformat|##FILTER|##FORMAT|##GATKCommandLine" | \
grep -v -E "ID=AS_" | grep -v "##INFO" >> ${work_dir}/gvcf/hdr.revise.txt
bcftools reheader -h ${work_dir}/gvcf/hdr.revise.txt -o ${work_dir}/gvcf/GenotypeGVCFs.newHeader.vcf.gz \
${work_dir}/gvcf/GenotypeGVCFs.vcf.gz

## Normallize
bcftools norm \
--fasta-ref ~/ref/seq/GRCh37.fa --multiallelics -any \
-O z --output ${work_dir}/gvcf/GenotypeGVCFs.norm.vcf.gz \
${work_dir}/gvcf/GenotypeGVCFs.newHeader.vcf.gz

tabix ${work_dir}/gvcf/GenotypeGVCFs.norm.vcf.gz

################################################################################

zcat GenotypeGVCFs.norm.vcf.gz | awk -F'\t' '{print $1,$2,$3,$19,$41}' | grep -E "68846047|CHROM"

JZ563B
JZGCWES0698